package org.apache.dolphinscheduler.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.Bill;
import org.apache.dolphinscheduler.dao.entity.Couponbill;
import org.apache.dolphinscheduler.dao.entity.Coupondetail;
import org.apache.dolphinscheduler.dao.vo.CouponBillVo;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 收支明细表 Mapper 接口
 * </p>
 *
 * @author denggh
 * @since 2023-08-14
 */
public interface CouponbillMapper extends BaseMapper<Couponbill> {

  IPage<CouponBillVo> selectCouponbillPage(Page<CouponBillVo> page,
                                               @Param("id") Integer id,
                                               @Param("couponName") String couponName,
                                               @Param("couponState") String couponState,
                                               @Param("billNo") String billNo,
                                               @Param("userAccount") String userAccount,
                                               @Param("userIdList") List<Integer> userIdList,
                                               @Param("issueType") String issueType,
                                               @Param("startDateClaim") String startDateClaim,
                                               @Param("endDateClaim") String endDateClaim,
                                               @Param("startDateUse") String startDateUse,
                                               @Param("endDateUse") String endDateUse,
                                               @Param("startDateEnd") String startDateEnd,
                                               @Param("endDateEnd") String endDateEnd);

  BigDecimal getTotalPaymentAmount(@Param("detailId") Integer detailId);

  BigDecimal getTotalPayableAmount(@Param("detailId") Integer detailId);

  Integer getTotalUserNum(@Param("detailId") Integer detailId);

  List<Map<String,Object>> getAvailablePlatCoupon(@Param("amount") Integer amount, @Param("userId") Integer userId);

  List<Map<String,Object>> getAvailableCollectCoupon(@Param("amount") Integer amount);

  List<Map<String,Object>> getUsedCouponBill(@Param("billNo") String billNo);

  void insertCouponBills(@Param("userIds") List<String> userIds, @Param("cD") Coupondetail coupondetail);
}
